﻿using FluentNHibernate;
using MadMediaManager.Core.DependencyInjectionSupport;
using MadMediaManager.Core.Interfaces.DependencyInjectionSupport;
using MadMediaManager.DataAccess.Database;

namespace MadMediaManager.Infrastructure
{
    public class InfrastructureConfigurer : IInfrastructureConfigurer
    {
        public void Configure()
        {
            var appSettings = new ApplicationSettings();
            var databaseCreator = new SqlCeDatabaseCreator(appSettings.ConnectionString);
            databaseCreator.Delete().Create();
            AppServiceContainer.Init(new ContainerConfigurator(new ApplicationSettings()));
            databaseCreator.Script(AppServiceContainer.Get<ISessionSource>().Configuration);
        }
    }
}
